home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 November / Pcwk1197.iso / LOTUS / Eng-ins / SMASTERS / APPROACH / DB2WWW.MPR / SCRIPT / ApproachDoc / WWW Assistant.s (.txt) < prev   
Null Bytes Alternating  |  1997-01-09  |  17KB  |  264 lines

  1. '++LotusScript Development Environment:2:5:(Options):0:66
  2.  
  3. '++LotusScript Development Environment:2:5:(Forward):0:1
  4. Declare Sub Switchto(Source As Form, View As VIEW)
  5. Declare Sub NewWinTitle
  6. Declare Sub ClearVals
  7. Declare Sub Pageswitch(Source As Form, Pagefrom As Long, Pageto As Long)
  8. Declare Sub Switchfrom(Source As Form, View As VIEW)
  9. Declare Sub SetPanel2
  10.  
  11. '++LotusScript Development Environment:2:5:(Declarations):0:2
  12.  
  13. '++LotusScript Development Environment:2:2:BindEvents:1:129
  14. Private Sub BindEvents(Byval Objectname_ As String)
  15.     Static Source As FORM
  16.     Set Source = Bind(Objectname_)
  17.     On Event Switchto From Source Call Switchto
  18.     On Event Pageswitch From Source Call Pageswitch
  19.     On Event Switchfrom From Source Call Switchfrom
  20. End Sub
  21.  
  22. '++LotusScript Development Environment:2:2:Switchto:1:12
  23. Sub Switchto(Source As Form, View As VIEW)
  24.     
  25.     'This will set the window title of the dialogue box:
  26.     NewWinTitle
  27.     
  28. '    CurrentApplication.visible = False
  29.     Dim Clearit(0) As String
  30.     Dim opendocs() As String 'Array of documents open
  31.     'Make sure the web assistant is the active view
  32.     'Go to the Web Assistant
  33.     'Duplicate - this is also in the open document event:
  34.     'Set CurrentWindow.Activeview =CurrentApplications.db2www.WWW~ Assistant
  35.     
  36.     
  37.     arycnt = 0
  38.     'Clear the values if this is the first time the assistant has been loaded
  39.     
  40.     If gFlagLoaded = 0 Then
  41.         Call ClearVals
  42.     End If
  43.     
  44.     'Make sure that all of the done buttons from panel 3 to 5 are blackened:
  45.     With CurrentDocument.WWW~ Assistant.body
  46.         .btnp3done.font.color.setrgb color_black
  47.         .btnp4done.font.color.setrgb color_black
  48.         .btnp5done.font.color.setrgb color_black
  49.     End With
  50.     
  51.         'Temporary - for re-running and testing
  52.     'If gCurPage=0 Then
  53.     '    gCurPage = 1
  54.     'End If
  55.     'Put the dialogue on the last  panel     used by user
  56.     On Error Resume Next
  57.     CurrentView.CurrentPageNum = gCurPage
  58.     
  59.     
  60.     
  61.     CurrentDocument.Modified = False
  62.     
  63. End Sub
  64. '++LotusScript Development Environment:2:2:NewWinTitle:1:8
  65. Sub NewWinTitle
  66.     'Rename the window title for the dialogue so that it has the title we want instead of the apr file name
  67.     Dim activeWin As Integer, winTitle As String
  68.     activeWin% = GetActiveWindow()
  69.     winTitle$ = "DB2 Web Sizing Assistant"
  70.     SetWindowTextA activeWin%, winTitle$
  71. End Sub
  72. '++LotusScript Development Environment:2:2:ClearVals:1:8
  73. Sub ClearVals
  74.     'Dim obtype As Long
  75.     Dim ClearIt(0) As String
  76.     Dim opendocs() As String 'Array of documents open
  77.     'blank out some values and set some default values
  78.     numrows = 0
  79.     c = 0
  80.     
  81.     'Let's empty the listbox for opendocs
  82.     
  83.     CurrentDocument.www~ assistant.body.lbopenapps.setlist(ClearIt)
  84.     CurrentDocument.www~ assistant.body.lbformsp2.setlist(ClearIt)
  85.     CurrentDocument.www~ assistant.body.lbReportsP2.setlist(ClearIt)
  86.     
  87.     '**************There's currently a problem with accesssing all the objects on a multipage form, so we'll specify
  88.     'what we want cleared:
  89.     With CurrentDocument.WWW~ Assistant.body
  90.         .txtimagepath.text = "\images"
  91.         .txtmacropath.text = ""
  92.         .txtExeName.text = ""
  93.         .txtnumrows.text=""
  94.         .cbxPromptUserid.setstate(True)
  95.         .cbxUseUserid.setstate(True)
  96.         .cbxUsePswd.setstate(True)
  97.         .rdoSqlOff.setstate(True)
  98.         .rdoSearchAnd.setstate(True)
  99.         .rdoNoConvert.setstate(True)
  100.         .rdoFormPost.setstate(True)
  101.         
  102.         
  103.         'Let's set default values into the Step 3 screen:
  104.         .txtUserid.readonly = 0
  105.         .txtPswd.readonly = 0
  106.         .txtUserid.background.color.setrgb color_white
  107.         .txtPswd.background.color.setrgb color_white
  108.         .txtUserid.text = "userid"
  109.         .txtPswd.text = "password"    
  110.         
  111.         'Default values in panel 4:
  112.         .txtNumRows.text = "0"  'The number of rows to return in the report
  113.         
  114.         'default values in panel 5:
  115.         .txtImagePath.text = "/images/"
  116.         .txtExeName.text = "/cgi-bin/db2www.exe"
  117.     End With
  118.     
  119.     Redim opendocs( 0 To CurrentApplication.Documents.count-1)
  120.     
  121.     
  122.     i = 0
  123.     Forall documents In CurrentApplication.documents
  124.         'Let's not bother to include the Web Assistant apr - this is confusing to users
  125.         If Left$(Lcase$(CurrentApplication.documents(i).name),6) <> "db2www" Then
  126.             CurrentDocument.www~ assistant.body.lbopenapps.addlistitem(CurrentApplication.documents(i).name)
  127.             opendocs(arycnt) = CurrentApplication.documents(i).name
  128.             arycnt = arycnt + 1
  129.         End If
  130.         i = i + 1
  131.     End Forall
  132.     '********End of filling the listbox
  133.     On Error Goto NoIndex
  134.     CurrentDocument.www~ assistant.body.lbopenapps.text = opendocs(0)
  135.     
  136.     
  137.     'Indicate that we've cleared this once and not to do it again
  138.     
  139.     gFlagLoaded = 1
  140.     
  141. NoIndex:
  142.     If Error = "Subscript out of range" Then
  143.         Exit Sub
  144.     End If
  145.     
  146. End Sub
  147. '++LotusScript Development Environment:2:2:Pageswitch:1:12
  148. Sub Pageswitch(Source As Form, Pagefrom As Long, Pageto As Long)
  149.     Dim Formselected As String, RptSelected As String    
  150.     
  151.     On Error Resume Next
  152.     Select Case CurrentView.currentpagenum
  153.     Case 1
  154.         gPageLoaded=0
  155.         MacName$ = "" 'Reset the macroname
  156.     Case 2
  157.         If CurrentDocument.www~ assistant.body.lbopenapps.text = "" Then
  158.             Messagebox "No Document Has Been Selected",, "Error"
  159.             CurrentView.currentpagenum = 1
  160.             Exit Sub
  161.         End If
  162.         If gPageLoaded = 0 Then
  163.             Call SetPanel2
  164.         End If
  165.     Case 3
  166.         Flag = 0
  167.         If MacName$ = "" Then
  168.             MacName$ =  Mid$(currentapplication.documents(DocIndex).fullname, 1, Len(currentapplication.documents(DocIndex).fullname)-3) &"d2w"        
  169.         End If
  170.         With CurrentDocument.WWW~ Assistant.body
  171.             rptAsForm = Val(.cbxRptAsForm.value)
  172.             If rptAsForm = 1 Then
  173.                 FormSelected =  .lbReportsP2.text
  174.             Else
  175.                 FormSelected = .lbformsP2.text
  176.             End If
  177.             RptSelected = .lbReportsP2.text    
  178.         End With    
  179.         If FormSelected = "" Then 'No Form was selected
  180.             Msgbox "You must select a form",, "No Form Selected"
  181.             CurrentView.currentpagenum = 2
  182.             End
  183.         End If
  184.         If RptSelected = "" Then 'No report was selected
  185.             Msgbox "You must select a Report",, "No Report Selected"
  186.             CurrentView.currentpagenum = 2
  187.             End
  188.         End If
  189.         CurrentDocument.www~ Assistant.body.txtMacName.text = MacName$
  190.     Case 4,5
  191.         If CurrentDocument.www~ Assistant.body.txtdbname.text = "" Then
  192.             Msgbox "Please fill in database name",, "Database name required"
  193.             Currentview.currentpagenum = 3
  194.             CurrentDocument.www~ Assistant.body.txtdbname.setfocus
  195.             End
  196.         End If
  197.         Macname$ = CurrentDocument.www~ assistant.body.txtMacName.text
  198.     End Select
  199.     
  200. WhatNow:
  201.     If Flag = 1 Then
  202.         PrevPage
  203.         Messagebox "Please make new selections that have the same main table",,"New Selection"
  204.         End
  205.     End If
  206.     
  207.     'Clear errors
  208.     Err = 0
  209. End Sub
  210. '++LotusScript Development Environment:2:2:Switchfrom:1:12
  211. Sub Switchfrom(Source As Form, View As VIEW)
  212.     Dim rval As Integer
  213.     'Check to see if we want to exit:
  214.     If  currentwindow.activeview.name <> "WWW Assistant" And currentwindow.activeview.name <> "Web Background" And currentwindow.activeview.name <> "Warning Message Table"Then
  215.         Call QuitAssistant()
  216.     End If
  217.     
  218.     
  219. End Sub
  220. '++LotusScript Development Environment:2:2:SetPanel2:1:8
  221. Sub SetPanel2
  222.     
  223.     If CurrentView.currentpagenum = 2 Then
  224.         Dim FrmList() As String 'Array of forms in the view
  225.         Dim RptList() As String  'Array of reports in the view
  226.         Dim ClearIt(0) As String
  227.         Dim DocSelected As String
  228.             'Empty the listboxes so that they don't have old info in them
  229.         
  230.         'CurrentApplication.db2www.www~ assistant.body.lbformsp2.setlist(ClearIt)
  231.         'CurrentApplication.db2www.www~ assistant.body.lbReportsP2.setlist(ClearIt)
  232.         
  233.         
  234.     'Put the user's selection in the global variable
  235.         DocSelected = CurrentDocument.www~ assistant.body.lbopenapps.text
  236.         DocIndex = GetDocIndex(DocSelected)
  237.         
  238.         
  239.     'Let's get the list of forms and reports from the selected document:
  240.         rvalForms = Getforms(DocIndex, frmlist)
  241.         rvalReports =  GetRpts(DocIndex, rptlist)
  242.         
  243.         
  244.         
  245.     'If there aren't any forms or reports found, then let the user know:
  246.         If rvalForms = 0 And rvalReports = 0 Then
  247.             Messagebox "No Reports or Forms found in the selected document" &_
  248.             Chr(10) & "Select another document", , "Error"
  249.             PrevPage
  250.             Exit Sub        
  251.         End If
  252.         
  253.         
  254.     'Let's stick those lists in the corresponding list boxes
  255.         CurrentDocument.www~ assistant.body.lbformsp2.setlist(frmlist)
  256.         CurrentDocument.www~ assistant.body.lbReportsP2.setlist(Rptlist)
  257.     'Let's make the first item in each list the default value:    
  258.         On Error Resume Next
  259.         CurrentDocument.www~ assistant.body.lbformsp2.text = FrmList(0)
  260.         CurrentDocument.www~ assistant.body.lbReportsP2.text = RptList(0)    
  261.         gPageLoaded = 1    
  262.     End If    
  263.     
  264. End Sub